﻿using System.Data;
using System.Xml;

namespace Symantec.DataFactories
{
    /// <summary>
    /// Represents a set of methods for creating instances of data factories
    /// </summary>
    public interface IDataFactory
    {
        /// <summary>
        /// Used to create a data factory command object.
        /// </summary>
        /// <returns>
        /// Returns a System.Data.IDbCommand.
        /// </returns>
        IDbCommand CreateCommand();

        /// <summary>
        /// Used to create a data factory connection object.
        /// </summary>
        /// <returns>
        /// Returns a System.Data.IDbCommand.
        /// </returns>
        IDbConnection CreateConnection();

        /// <summary>
        /// Used to create a data factory data adapter object.
        /// </summary>
        /// <returns>
        /// Returns a System.Data.IDbDataAdapter
        /// </returns>
        IDataAdapter CreateDataAdapter();

        /// <summary>
        /// Provides method to check if implementation of IDataFactory supports XmlReader.
        /// </summary>
        bool SupportsXmlReader { get; }

        /// <summary>
        /// Used to execute the IDbCommand, if supported, and create an XmlReader object.
        /// </summary>
        /// <returns>
        /// Returns a System.Xml.XmlReader.
        /// </returns>
        XmlReader ExecuteXmlReader();

        /// <summary>
        /// Used to execute the IDbCommand and create an IDataReader object.
        /// </summary>
        /// <returns>
        /// Returns a System.Data.IDataReader.
        /// </returns>
        IDataReader ExecuteReader();

        /// <summary>
        /// Use to execute the command and fill a supplied DataTable object with the query results,
        /// returning the number of rows added to the DataTable.
        /// </summary>
        /// <param name="result">
        /// DataSet object to fill.
        /// </param>
        /// <returns>
        /// Returns the count of rows added to the DataSet.
        /// </returns>
        int Fill(DataSet result);
    }
}
